<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../../common/meta.jsp"%>
		<script type="text/javascript">
	var cityareaname = new Array(3);
	var cityareacode = new Array(3);
	function first(preP, preC, formname, trainerType, trainerGrade) {
		
	a = 0;
	if (trainerType == 'TRAINERTYPE_A') {
		a = 1;
		tempoption = new Option('内勤人员', 'TRAINERTYPE_A', false, true);
	} else {
		tempoption = new Option('内勤人员', 'TRAINERTYPE_A');
	}
	eval('document.' + formname + '.' + preP + '.options[1]=tempoption;');
	cityareacode[0] = new Array('TRAINERLEVEL_01', 'TRAINERLEVEL_02',
			'TRAINERLEVEL_03');
	cityareaname[0] = new Array('初级讲师', '中级讲师', '高级讲师');

	if (trainerType == 'TRAINERTYPE_B') {
		a = 2;
		tempoption = new Option('内勤人员', 'TRAINERTYPE_B', false, true);
	} else {
		tempoption = new Option('外勤人员', 'TRAINERTYPE_B');
	}
	eval('document.' + formname + '.' + preP + '.options[2]=tempoption;');
	cityareacode[1] = new Array('TRAINERGRADE_01', 'TRAINERGRADE_02',
			'TRAINERGRADE_03', 'TRAINERGRADE_04', 'TRAINERGRADE_05',
			'TRAINERGRADE_06', 'TRAINERGRADE_07', 'TRAINERGRADE_08');
	cityareaname[1] = new Array('D级讲师', 'D+级讲师', 'C级讲师', 'C+级讲师', 'B级讲师',
			'B+级讲师', 'A级讲师', 'A+级讲师');

	eval('document.' + formname + '.' + preP + '.options[a].selected=true;');
	 
	cityid = trainerType;
	if (cityid != '0') {
		b = 0;
		for (i = 0; i < cityareaname[cityid - 1].length; i++) {
			if (trainerGrade == cityareacode[cityid - 1][i]) {
				b = i + 1;
				tempoption = new Option(cityareaname[cityid - 1][i],
						cityareacode[cityid - 1][i], false, true);
			} else
				tempoption = new Option(cityareaname[cityid - 1][i],
						cityareacode[cityid - 1][i]);
			eval('document.' + formname + '.' + preC
					+ '.options[i+1]=tempoption;');
		}
		eval('document.' + formname + '.' + preC + '.options[b].selected=true;');

	}

	//debugger;
	var trainer = '${trainerType}';

	if (trainer != '') {
		document.getElementById("triantype").value = trainer;
		selectcityarea('trainerType', 'trainerGrade', 'getFrom');
		var traingrede = '${trainerGrade}';
		document.getElementById("traingrade").value = traingrede;
	}

}
function selectcityarea(preP, preC, formname) {

	cityid = eval('document.' + formname + '.' + preP + '.selectedIndex;');
	j = eval('document.' + formname + '.' + preC + '.length;');
	for (i = 1; i < j; i++) {
		eval('document.' + formname + '.' + preC + '.options[j-i]=null;')
	}
	if (cityid != "0") {
		for (i = 0; i < cityareaname[cityid - 1].length; i++) {
			tempoption = new Option(cityareaname[cityid - 1][i],
					cityareacode[cityid - 1][i]);
			eval('document.' + formname + '.' + preC
					+ '.options[i+1]=tempoption;');
		}
	}

}
$(function() {

	$(".delTrain")
			.click(
					function() {
						var saletrainerid = $(this).attr("val");
						var url = "${path}/productandtrain/lecturer/index/deletetrainer/"
								+ saletrainerid;
						art.dialog( {
							lock : true,
							content : '确定要删除吗?',
							ok : function() {
								art.dialog( {
									id : "loading",
									lock : true,
									drag : false,
									resize : false,
									title : "正在删除..."
								});
								$.post(url, null, function(result) {
									art.dialog( {
										id : 'loading'
									}).close();//关闭等待框
										if (result == "true") {
											art.dialog( {
												icon : "succeed",
												content : "删除成功!",
												lock : true,
												ok : function() {
													location.reload();
												}
											});
										} else {
											art.dialog( {
												icon : "error",
												content : "删除失败!",
												lock : true,
												ok : true
											});
										}

									});

								return true;
							},
							cancelVal : '关闭',
							cancel : true
						//为true等价于function(){}
								});
					});
});
</script>

	</head>
	<body id="master">
		<sfa:mainHeader></sfa:mainHeader>
		<div class="webpart3 contentarea">
			<div class="webpart-head">
				<div class="webpart-head-item">
					讲师管理
					<div class="tools-btn">
						<a href="${path}/productandtrain/lecturer/index/addtrainer"><span>
								<img src="${path}/statics/images/add2.gif"
									style="margin-right: 4px;" />新建</span> </a>
					</div>
				</div>
			</div>
			<div class="webpart-main">
				<div class="webpart-main-item" style="padding-top: 12px;">
					<div class="search">
						<form method="get" name="getFrom">
							<table cellpadding="0" cellspacing="0" align="center">
								<tr>
									<td>
										讲师姓名
									</td>
									<td>
										<input type="text" class="input-txt" name="trainerName"
											id="trainerName" value="${trainerName}" />
									</td>

									<td>
										所属机构
									</td>
									<td>
										<select class="selectbox" name="branchId" id="branchId">
											<option value="ALL">
												全部
											</option>
											<c:forEach items="${BranchList}" var="branch">
												<option value="${branch.branchId }"
													<c:if test="${branchId==branch.branchId }">selected='selected'</c:if>>
													${branch.branchName}
												</option>
											</c:forEach>
										</select>
									</td>
									<td>
										讲师职级
									</td>
									<td>
										<select id="traingrade" name="trainerGrade"
											style="width: 80px;">
											<option value="ALL">
												全部
											</option>
										</select>
									</td>
									<td>
										<input type="submit" class="linkbtn2" value="查询" />
									</td>
								</tr>
								<tr>
									<td>
										兼讲类型
									</td>
									<td>
										<select id="triantype" name="trainerType"
											onChange="selectcityarea('trainerType','trainerGrade','getFrom');">
											<option value="ALL">
												全部
											</option>
										</select>
									</td>
									<td align="right" colspan="6">

										<input type="button" class="linkbtn2" value="重置"
											onclick="location.href='${path}/productandtrain/lecturer/index/trainer';" />
									</td>
								</tr>
							</table>
						</form>
						<script language="javascript">
first("trainerType", "trainerGrade", "getFrom", 0, 0);
</script>
					</div>
					<!----------- 数据列表 ------------------>
					<table cellpadding="0" cellspacing="0"
						class="dg_borderstyle trStyleTable" style="margin-top: 15px;">
						<tr>
							<th>
								序号
							</th>
							<th>
								机构
							</th>
							<th>
								姓名
							</th>
							<th>
								初始授课时间
							</th>
							<th>
								职级
							</th>
							<th>
								积分
							</th>
							<th>
								擅长课程
							</th>
							<th>
								兼讲类型
							</th>
							<th>
								操作
							</th>
						</tr>

						<c:forEach items="${pagination.resultList}" var="trainer"
							varStatus="ind">
							<tr>
								<td align="center">
									${(pagination.page-1)*10+(ind.index+1)}
								</td>
								<td align="left">
									${trainer.branchname}
								</td>
								<td align="center">
									${trainer.trainername }
								</td>
								<td align="center">
									<fmt:formatDate value="${trainer.trainstratdate}"
										pattern="yyyy-MM-dd" />
								</td>
								<td align="center">
									${trainer.trainerlevelname}
								</td>
								<td align="center">
									${trainer.sort }
								</td>
								<td align="center" width="70">
									<div
										style="display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 70px;"
										title="${trainer.goodatitem}">
										${trainer.goodatitem }
									</div>
								</td>
								<td align="center">
									${trainer.trainertypeanme}
								</td>
								<td align="center" width="70">
									<a
										href="${path}/productandtrain/lecturer/index/edittrainer/${trainer.saletrainerid}">编辑
									</a> |
									<a class="delTrain" href="javascript:void(0);"
										val="${trainer.saletrainerid}">删除</a>

								</td>
							</tr>
						</c:forEach>
					</table>
					<!----------- 翻页导航 ------------------>
					<div class="dg_pagerstyle">
						<div class="pageinfo">
							<c:if test="${not empty pagination.multiPage}">
							   第${pagination.page }页 | 共${pagination.totalPages }页/${pagination.totalRows }条记录
						</c:if>

						</div>
						<div class="pagebtn">
							${pagination.multiPage}
						</div>
					</div>
				</div>
				<div class="webpart-foot">
					<div class="webpart-foot-item">
					</div>
				</div>
			</div>
		</div>
		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>